import http from '@/utils/http/axios';

/**
 * @description: 根据用户id获取用户菜单
 */
export function adminMenus() {
  return http.request({
    url: '/menus',
    method: 'GET',
  });
}

/**
 * 获取tree菜单列表
 * @param params
 */
export function getMenuList(params?) {
  return http.request({
    url: '/menu/list',
    method: 'GET',
    params,
  });
}

// 添加菜单
export function addMenuApi(params = {}) {
  return http.request({
    url: '/system/sysMenu',
    method: 'POST',
    params,
  });
}

// 修改菜单
export function modifyMenuApi(params = {}) {
  return http.request({
    url: '/system/sysMenu',
    method: 'PUT',
    params,
  });
}

// 通过菜单参数分页获取用户数据
export function getMenuTreeApi(params = {}) {
  return http.request({
    url: '/system/sysMenu/getTree',
    method: 'GET',
    params,
  });
}

// 通过菜单参数分页获取用户数据
export function getMenuTreeByToken(params = {}) {
  return http.request(
    {
      url: '/system/sysMenu/getMenuTreeByToken',
      method: 'GET',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

// 删除菜单
export function deleteMenuApi(params) {
  return http.request({
    url: `/system/sysMenu/${params.id}`,
    method: 'DELETE',
  });
}
